//
//  ViewAnimation.m
//  easyTaxi
//
//  Created by ellenpage on 13-1-6.
//  Copyright (c) 2013年 ellenpage. All rights reserved.
//

#import "ViewAnimation.h"

@implementation ViewAnimation

+(void)viewAnimation:(NSInteger)i view:(UIView *)view
{

    CGContextRef context = UIGraphicsGetCurrentContext();
    
	//开始准备动画
	[UIView beginAnimations:@"pageCurl" context:context];
    
	//设置动画曲线，翻译不准，见苹果官方文档
	[UIView setAnimationCurve:UIViewAnimationCurveLinear];
    
    
    //设置动画持续时间
	[UIView setAnimationDuration:1.0f];
    
    switch (i)
    {
        case 0:
        {
            //设置动画效果
            [UIView setAnimationTransition: UIViewAnimationTransitionCurlDown forView:view cache:YES];//从上向下
        }
            break;
            
        case 1:
        {
            [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp   forView:view cache:YES];//从下向上
        }
            break;
            
        case 2:
        {
            [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:view cache:YES];  //从左向右
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//3先慢 后快 在慢

        }
            break;
            
        case 3:
        {
            [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:view cache:YES];//从右向左
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//3先慢 后快 在慢
        }
            break;
        default:
            break;
    }
    
	//设置动画委托
    [UIView setAnimationDelegate:self];
    
	//当动画执行结束，执行animationFinished方法
//    [UIView setAnimationDidStopSelector:@selector(animationFinished:)];
    
	//提交动画
	[UIView commitAnimations];
}

@end
